<template>
	<view class="uni-task-item bcl-white p-10">
		<!-- 用户信息 -->
		<view class="user-info box box-between">
			<view class="box box-center" @tap="toDetailPage">
				<view class="uni-avatar mr-5">
					<image :src="item.avatar || defaultImage" />
				</view>
				<view class="name hide-text-2 mr-5">{{ item.username }}</view>
				<view class="uni-vip" v-if="item.vip_name != '普通用户'"></view>
			</view>

			<!-- 地区 -->
			<view class="box box-center cl-second" v-if="item.province_name">
				<!--<text class="icon icon-location fz-14"></text>-->
				<text @click="copyorder_sn(item.task_sn)">{{ item.task_sn }}</text>
				<image src="../static/images/share.png" style="width: 35rpx;height: 35rpx;margin-top: -60rpx;" @click="onShare(item.id,item.title,item.create_at)"></image>
			</view>
		</view>

		<!-- 标题 -->
		<view class="title fz-15 bold mt-10" @tap="toDetailPage">{{ item.title }}</view>

		<!-- 标签列表 -->
		<!-- <view class="tag-list mt-5">
      <view class="uni-tag">{{ item.type_name }}</view>
      <view class="uni-tag" v-if="item.commission > 0"
        >推广{{ item.commission }}元</view
      >
      <view class="uni-tag">急</view>
    </view> -->

		<!-- 赏金 -->
		<view class="money box box-between box-column-center border border-bottom pt-5 pb-5" @tap="toDetailPage">
			<view class="cl-main fz-24 bold">
				<text>￥</text>
				<text>{{ item.bounty }}</text>
			</view>

			<view>
				<!-- 按钮状态 -->
				<block v-if="item.status <= 4">
					<button class="uni-button ml-10" style="width: 30px;height: 30px;padding: 2px;border-radius: 50%;
            line-height: 25px;text-align: center;border: 0px solid transparent;"
					 v-if="parseInt(item.surplus_times) > 0">
						抢
					</button>
				</block>

				<block v-else-if="item.status == 5">
					<button class="uni-button ml-10" disabled>
						{{ item.selected_work_at ? "选稿中" : "已中标" }}
					</button>
				</block>

				<block v-else-if="item.status == 6">
					<button class="uni-button ml-10" disabled>
						{{ item.publicity_at ? "待公布" : "已公布" }}
					</button>
				</block>

				<block v-else-if="item.status == 7">
					<button class="uni-button ml-10" disabled>
						{{ item.checked_at ? "待验收" : "已验收" }}
					</button>
				</block>

				<block v-else-if="item.status == 8">
					<button class="uni-button ml-10" disabled>
						{{ item.comment_at ? "待评价" : "已评价" }}
					</button>
				</block>

				<block v-else-if="item.status == 9">
					<button class="uni-button ml-10" disabled>任务已完成</button>
				</block>

				<block v-else-if="item.status == 10">
					<button class="uni-button ml-10" disabled>失败</button>
				</block>

				<block v-else-if="item.status == 11">
					<button class="uni-button ml-10" disabled>维权</button>
				</block>

				<block v-else-if="item.status == 12">
					<button class="uni-button ml-10" disabled>修改中</button>
				</block>

				<block v-else-if="item.status == 13">
					<button class="uni-button ml-10" disabled>交付中</button>
				</block>
			</view>
		</view>

		<!-- 其他信息 -->
		<view class="extra box box-between fz-12 cl-second mt-10" @tap="toDetailPage">
			<!-- <text>{{ item.show_publish }}</text> -->
			<text>{{ item.view_count || 0 }}人浏览/{{
          item.delivery_count || 0
        }}人投标</text>

			<!-- 剩余时间 -->
			<text v-if="parseInt(item.surplus_times) > 0">
				<text>剩余</text>
				<text class="ml-5 cl-main">{{ item.surplus_times }}</text>
			</text>

			<text class="cl-main" v-else>已截止</text>
		</view>

		<!-- 发布按钮 -->
		<!-- <div
      class="send-btn pointer"
      @click="toSendPage"
    >
      <image
        src="/static/images/release_1.png"
        style="width: 50px; height: 50px;"
      ></image>
    </div> -->
	</view>
</template>

<script>
	import uniCopy from "@/apis/uni-copy.js";
	//  import uniCopy from '@/js_sdk/xb-copy/uni-copy.js'
	// #ifdef APP-PLUS
	import appShare, {
		closeShare
	} from "@/utils/share";
	// #endif
	export default {
		name: "uniTaskItem",

		props: {
			item: {
				type: Object,
				default: {},
			},
		},

		data() {
			return {
				defaultImage: this.$config.default,
			};
		},

		// 微信小程序分享
		onShareAppMessage() {
			return {
				title: '任务大厅',
				path: `/pages/index/index`,
			};
		},

		methods: {
			toSendPage() {

				let url = uni.getStorageSync("userInfo")
				if (url) {
					uni.navigateTo({
						url: '/pages/index/release/submit?type=1'
					});

				} else {

					uni.navigateTo({
						url: "/user/login"	});
				}
			},
			copyorder_sn(value) {
				uniCopy({
					content: value,
					success: (res) => {
						uni.showToast({
							title: res,
							icon: 'none'
						})
					},
					error: (e) => {
						uni.showToast({
							title: e,
							icon: 'none',
							duration: 3000,
						})
					}
				})
			},
			toDetailPage() {
				// uni.navigateTo({
				// 	url:'/user/info/userInfoDetail'
				// });
				// return;
				var userInfo = uni.getStorageSync("userInfo")
				if (userInfo) {

					if (userInfo.is_realname == 0) {
						this.$toast("实名认证后方可查看详情");
					} else {
						uni.navigateTo({
							url: `/task/detail?id=${this.item.id}`,
						});

					}

				} else {
					uni.navigateTo({
						url: "/user/login"	});
				}
				console.log("354231213", userInfo.is_realname)

				// if(userInfo.is_realname == 0){
				//    this.$toast("实名认证后方可查看详情");
				// }else{
				//   uni.navigateTo({
				//     url: `/task/detail?id=${this.item.id}`,
				//   });

				// }
				// alert(1)
				// uni.navigateTo({
				//   url: `/task/detail?id=${this.item.id}`,
				// });
			},
			//原生app分享
			onShare(id, title, tiem_desc1) {
				console.log('xxxxxxx', title);
				// #ifdef APP-PLUS 
				let shareData = {
					shareUrl: this.$config.host + `/task/detail?id=` + id,
					shareTitle: title,
					shareContent: tiem_desc1,
					shareImg: "/static/images/logo_circle.png",
				};

				// 调用
				let shareObj = appShare(shareData, (res) => {
					console.log("分享成功回调", res);
					closeShare();
				});
				// #endif
			},
		},
	};
</script>

<style lang="scss" scoped></style>
